import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

public class CollectionExercise {

    public static void main(String[] args) {
        Dog dog = new Dog("小王", 11);
        Dog dog1 = new Dog("小张", 12);
        Dog dog2 = new Dog("小明",13);
        // ArrayList 实现List接口，
        // List接口实现Collection接口，所以越低下越老哒
        List list = new ArrayList();
        //Collection list1 = new ArrayList();

        list.add(dog);
        list.add(dog1);
        list.add(dog2);
        /**
         *
         * list.add(new Dog("", ))
         */

        System.out.println("list1 = " + list);

        // 迭代器
        // for增强 I + enter
        for (Object o : list) {
            System.out.println("o" + o);
        }


        Iterator iterator = list.iterator();

        while (iterator.hasNext()) {
            Object next =  iterator.next();
            System.out.println("next2 = " +  next);
        }

        int [] num = {22, 33, 44, 55};
        for (int i : num) {
            System.out.println("list3 = " + list);
        }


    }
}
class Dog{
    private String name;
    private int age;

    public Dog(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Dog{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
